package com.bstek.xxlJob.jobhandler;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

/**
 * @Title: 分片任务的基本使用
 * @Package: com.bstek.xxlJob.jobhandler
 * @Description:
 * @Author: zxq
 * @Date: 2023/12/3 - 21:30
 */

@Component
public class ShardingHandler {


    @XxlJob("sendMessageShardingHandler")
    public ReturnT<String> sendMessageShardingHandler()throws Exception{
       //获取传送过来的参数
        String param = XxlJobHelper.getJobParam();
        // 分片序号（当前执行器序号）
        int shardIndex = XxlJobHelper.getShardIndex();
        //分片总数,执行器总数
        int shardTotal = XxlJobHelper.getShardTotal();

        System.out.println("hello world");
        XxlJobHelper.log("给任务添加日志...");

        return ReturnT.SUCCESS;

    }


}
